Displaying Multiple Tables with a View

Description

The Web Component Builder provides two methods for displaying data from multiple tables. The View technique combines fields from 2 or more tables in one-to-one relationships.

The Displaying Multiple Tables with a View topic describes a technique available to Alpha Anywhere database users. A different kind of view is available in SQL Databases that can be used for a similar purpose, except that SQL views can reflect one-to-many relationships.

Creating a Grid Component

  1. Create a new grid based on the AlphaSports database.

  2. Display the Component Type page.

  3. Leave the Grid Layout selection as "Tabular". This produces a multi-record view, similar to a conventional Alpha Anywhere browse, with field labels at the tops or bottoms of columns.

  4. Select the Updateable radio button.

  5. Check the Grid contains a 'Search' part check box. This is an optional form that allows you to query your table and return matching records.

Selecting the Data Source

  1. Display the Grid > Data Source page.

  2. Select either the Alpha Anywhere .dbf Tables or ADO/ODBC/Access radio buttons. The ADO/ODBC/Access button allows you to retrieve your data from Microsoft Access or a database that supports the ADO or ODBC interface standards.

Selecting the Records to Display

If you selected Alpha Anywhere .dbf Tables :

  1. Display the Grid > Query (DBF) page.

  2. Select the View radio button.

  3. Click Tables in View to display the Define Join dialog box.

  4. Click Add Table to display the Add Table dialog box.

  5. Select "Product" from the Tables list and click OK .

  6. Select the Product table in the Define Join window and click Add Table to display the Add Table dialog box.

  7. Select "Invoice_Items" from the Tables list and click OK.

  8. Select the Invoice_Items table in the Define Join window and click Add Table to display the Add Table dialog box.

  9. Select "Invoice_Header" from the Tables list and click OK .

  10. Click OK to exit from the Define Join dialog box.

If you selected ADO/ODBC/Access :

  1. Display the Grid > Query (ADO) page.

  2. Select the SQL Select Statement radio button.

  3. Click Edit SQL to display the SQL Builder dialog box.

  4. Click Tables in Query to display the Add Table dialog box.

  5. Select "Invoice_Header" from the Tables list and click OK .

  6. Select "Invoice_Items" from the Tables list and click OK .

  7. Select "Product" from the Tables list and click OK > OK.

  8. Click Fields in Query to display the Select Fields in Query dialog.

  9. Select the "Date" field and click the '>' icon.

  10. Select the "Invoice_Items" table from the drop down list.

  11. Select the "Price", "Quantity", and "Extension" fields, and click the '>' icon.

  12. Select the "Product" table from the drop down list.

  13. Select the "Product_Id" and "Description" fields, and click the '>' icon.

  14. Click OK > OK to return to the Grid Builder.

Selecting the Fields to Display

  1. Click Fields in View to display the Select Fields in View dialog box.

  2. Add Product table fields. Select the "Product_Id" and "Description" fields, and click the '>' icon.

  3. Add Invoice_Items table fields. Select the "Price", "Quantity", and "Extension" fields, and click the '>' icon.

  4. Add an Invoice_Header table field. Select the "Date" field and click the '>' icon.

  5. Click OK to exit from the Select Fields in View dialog box.

  6. In the Filter field enter the expression Quantity > 0.

  7. Leave the Order field empty.

  8. Leave the Ascending radio button selected.

  9. Leave the Unique records only check box cleared.

  10. Leave the Read only check box cleared.

  11. Display the Grid > Fields page.

  12. Leave the Grid is editable check box unchanged.

  13. In the Available Fields list select "Product_Id" through "Date" and click the '>' icon.

Modifying Field Properties

  1. Select the "Product_Id" field in the Selected Fields list. Set the Textbox Properties > Size field to 4.

  2. Select the "Description" field in the Selected Fields list. Set the Textbox Properties > Size field to 40.

  3. Select the "Price" field in the Selected Fields list.

    • Click the '...' button in the Display Settings > Display Format field to display the Display Format dialog box.

    • Click Select Pre-Defined Format, select a currency format, and click OK > OK.

    • Set the Textbox Properties > Size field to 8.

  4. Select the "Quantity" field in the Selected Fields list. Set the Textbox Properties > Size field to 4.

  5. Select the "Extension" field in the Selected Fields list.

    • Click the '...' button in the Display Settings > Display Format field to display the Display Format dialog box.

    • Click Select Pre-Defined Format, select a currency format, and click OK > OK.

    • Set the Textbox Properties > Size field to 8.

  6. Select the "Date" field in the Selected Fields list.

    • Click the '...' button in the Display Settings > Display Format field to display the Display Format dialog box.

    • Click Select Pre-Defined Format, select a date format, and click OK > OK.

    • Set the Textbox Properties > Size field to 10.

Formatting the Grid

  1. Display the Grid > Properties page.

  2. Click the 'down' icon to display the Select style dialog.

  3. Select "WinClassic" click OK.

  4. Set the Layout Options > Rows of data field to 6.

  5. Click the Layout Options menu to collapse it.

  6. Check the Shading and Dividers > Alternate row shading check box.

  7. Select each field in the Selected Fields list to display its Field Properties dialog. Refer to Setting Grid Control Properties.

  8. Click the Shading and Dividers menu to collapse it.

  9. Click the Column Titles and Sorting Options menu to collapse it.

  10. Click the '...' button in the Record Navigator > Record navigator layout field to display the Record Navigator Designer dialog box. You can modify the default navigator styles or create new navigator styles.

  11. Select the following Pre-Defined Format and click OK:

    images/WPT_Record_Navigator_2.gif

Setting Update Properties

The update settings control how your grid behaves when a user adds, deletes, or updates a record.

  1. Display the Update > Settings page.

  2. Change the Permissions > Number of new record rows field to 1.

Defining the Search Form

The Search form allows you to find records using complete or partial values in one or more fields. You can sort the results on any field in the grid. You can display any set of fields from the table.

  1. Display the Search > Fields page.

  2. Select all fields in the Available Fields list and click the '>>' icon.

  3. Display the Search > Properties page.

  4. Clear the Records per Page Listbox Options > Include "Records per Page' listbox check box. This option allows the user to specify how many records to return per page.

Previewing the Grid

  1. The first stage of previewing your work is to create a page onto which to place the new component.

    • Click 'Save' to preserve your work. Name it "AlphaSports_Grid_4".

    • Click Close to return to the Web Projects Control Panel .

    • Click the following on the toolbar.

      images/New_Query_button.gif
    • Select Alpha Anywhere Web Page > OK to open the HTML Editor .

    • Click File > Save As. Name the page "AlphaSports_Page_4" and click OK.

  2. The next stage is to place the component on the page.

    • Click the 'lamp' icon i.e. Insert Component to display the Insert Component dialog.

      images/Genie_button.gif
    • Click Select to display the Select Component dialog.

    • Select "AlphaSports_Grid_4" and click OK.

    • Change the component Alias to "ACG4" and click OK.

    • Click 'Save' and close the HTML Editor.

  3. Next, publish the files to the local webroot. The local webroot is presumably the location where you will test your website. In most cases you will create a second profile (in this case "AlphaSports") where you will publish your finished public website.

    • 1. Display the A5W Pages page of the Web Projects Control Panel.

    • 2. Right click "AlphaSports_Grid_4" and select Publish (local webroot) and open. You should see something like the following.

      images/WPT_CVG_Grid.gif
  4. Finally, see how the component works. Enter ">100" into the Price field and click Search. You should see something like this.

    images/WPT_View_Quantity_Query_Results.gif
  5. Click Clear Search Criteria, enter "techelon" into the Description field and click Search.

    images/WPT_View_Text_Query_Results.gif
  6. Select a record and click the calendar icon next to its date field.

    images/WPT_Date_Picker.gif